import { Photo } from 'src/photo/photo.entity';
import { Column, Entity, PrimaryGeneratedColumn, OneToMany, JoinColumn, JoinTable } from 'typeorm';

@Entity('category')
export class Category {
  /**
   * 自增主键
   */
  @PrimaryGeneratedColumn({
    comment: '自增ID'
  })
  id: number;

  @Column({
    comment: '分类名'
  })
  name: string;

  @Column({
    comment: '创建时间'
  })
  create_time: number;

  @Column({
    comment: '更新时间'
  })
  update_time: number;

  @Column({
    comment: '删除时间'
  })
  delete_time: number;

  @OneToMany((type) => Photo, (photo) => photo.category)
  @JoinColumn({ name: 'category_id' })
  photos: Photo[];
}